@section('scripts')
<script type="text/javascript">
$(document).ready(function(){
	$('#publishedSelect').change(function(){
		$('#selectForm').submit(); 
	});
});
</script>
@stop

@section('content')
<div class="row">
	<div class="col-md-6">
		<h2>All the products</h2>
	</div>
</div>

<div class="row">
	<div class="col-md-4">
		<p>
		{{ Form::open(array('url' => 'admin/product', 'method' => 'get', 'id' => 'selectForm', 'role' => 'form')) }}
			{{ Form::select(
				'published',
				['' => 'All', '0' => 'Disable', '1'	=> 'Enable'], 
				$published, 
				['id' => 'publishedSelect' ,'class' => 'form-control']
			) }}
		{{ Form::close() }}
		</p>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
		<table class="table table-hover table-striped table-bordered">
		<thead>
			<tr>
				<th>ID</th>
				<th>Name</th>
				<th>Actions</th>
			</tr>
		</thead>
		<tbody>
			@foreach($products as $product)
			<tr>
				<td>{{ $product->id }}</td>
				<td>{{ $product->name }}</td>
				<td>
					{{ Form::open(array('url' => 'admin/product/' . $product->id, 'class' => 'pull-right')) }}
						{{ Form::hidden('_method', 'DELETE') }}
						{{ Form::submit('Delete this product', array('class' => 'btn btn-warning')) }}
					{{ Form::close() }}
					<a class="btn btn-small btn-success" href="{{ url('admin/product/' . $product->id) }}">Show this product</a>
					<a class="btn btn-small btn-info" href="{{ url('admin/product/' . $product->id . '/edit') }}">Edit this product</a>
				</td>
			</tr>
			@endforeach
		</tbody>
		</table>
	</div>
</div>
@stop